import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/Layout';

Vue.use(VueRouter)

const routes = [
  { path: '/', component: Layout },
]
const router = new VueRouter({
  mode: 'history', // 去掉url中的#
  routes
})
router.beforeEach((to, from, next) => {
  next()
})
// 防止跳转报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) {
    return originalPush.call(this, location, onResolve, onReject)
  }
  return originalPush.call(this, location).catch(err => err)
}
export default router
